package top.ningmao.myspring.common;

import top.ningmao.myspring.bean.BeansException;
import top.ningmao.myspring.bean.Car;
import top.ningmao.myspring.bean.factory.config.BeanPostProcessor;

/**
 * @author ningmao
 * @since 2025-5-9
 */
public class CustomerBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("CustomerBeanPostProcessor#postProcessBeforeInitialization");
        //换兰博基尼
        if ("car".equals(beanName)) {
            ((Car) bean).setBrand("lamborghini");
        }
        return bean;
    }
    
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("CustomerBeanPostProcessor#postProcessAfterInitialization");
        return bean;
    }
}
